using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.TeamFoundation.VersionControl.Client;
using Ltf.Remoting.Commands;
using Ltf.Remoting.TeamFoundation;

namespace Ltf.Remoting.Operations
{
	public class ServerOperators
	{
		private VersionControlServer server;

		public ServerOperators(VersionControlServer server)
		{
			this.server = server;
		}

		public void GetVersionInfo(string path, out string localPath, out string serverPath, out int localVersion, out int serverVersion)
		{
			serverVersion = localVersion = 0;
			serverPath = localPath = string.Empty;
			Item item = server.GetItem(path);

			if (item != null)
			{
				serverPath = item.ServerItem;
				serverVersion = item.ChangesetId;
			}

			ExtendedItem[] extItems = server.GetExtendedItems(path, DeletedState.Any, ItemType.Any);
			if (extItems.Length > 0)
			{
				ExtendedItem extItem = extItems[0];
				localVersion = extItem.VersionLocal;
				serverVersion = extItem.VersionLatest;
				localPath = extItem.LocalItem;
			}
		}

		
	}
}
